package com.winz.cultureapp.activity;

import android.content.Intent;
import android.webkit.WebView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.winz.cultureapp.R;
import com.winz.cultureapp.base.BaseAppCompatActivity;
import com.winz.cultureapp.constants.Constants;
import com.winz.cultureapp.entity.PublicationListBean;
import com.winz.cultureapp.jiaozi.JzvdStdMp3;

import butterknife.BindView;
import butterknife.OnClick;
import cn.jzvd.JzvdStd;

/**
 * 研究成果及多媒体出版物 -- MP3播放
 */
public class PublicationMp3Activity extends BaseAppCompatActivity {

    @BindView(R.id.jz_mp3)
    JzvdStdMp3 mJz_mp3;
    @BindView(R.id.tv_content)
    TextView mTv_content;
    @BindView(R.id.wv_content)
    WebView mWv_content;

    private PublicationListBean.DataBean.ListBean data;

    @Override
    protected int contentView() {
        return R.layout.activity_public_mp3;
    }

    @Override
    protected void initViews() {
        fullScreen(this);
    }

    @Override
    protected void loadDatas(Intent intent) {
        if (intent != null){
            if (intent.getExtras() != null){
                data = (PublicationListBean.DataBean.ListBean) intent.getExtras().getSerializable(Constants.KEY.PUBLICATION.DATA);
                if (data != null){
                    mJz_mp3.setUp(data.contentUrl
                            , "", mJz_mp3.SCREEN_WINDOW_NORMAL);
                    Glide.with(this)
                            .load(data.imageUrl)
                            .error(R.drawable.pic_default)
                            .into(mJz_mp3.thumbImageView);
                    mTv_content.setText(data.description);
                    mWv_content.loadDataWithBaseURL(null, data.content, "text/html", "utf-8",null);
                }
            }
        }
    }


    @Override
    public void onBackPressed() {
        if (mJz_mp3.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mJz_mp3.releaseAllVideos();
    }


    @OnClick(R.id.fl_back)
    public void onClick() {
        finish();
    }
}
